/**
 * 
 */
package com.nouvasys.sample.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author Ashwath
 *
 */
public final class SpringBeanFactory {
    /**
     * Private constructor.
     */
    private SpringBeanFactory() {
    }

    /**
     * 
     */
    private static ApplicationContext myContext = new ClassPathXmlApplicationContext(
            "applicationContext.xml");

    /**
     * @return The Spring ApplicationContext for JPMC Portal Application
     * @see ApplicationContext
     */
    public static ApplicationContext getApplicationContext() {
        if (myContext != null) {
            return myContext;
        } else {
            throw new IllegalAccessError(
                    "Circular reference in accessing application context. "
                            + "Do not assign application context in the constructor or class level "
                            + "variables.");
        }
    }
}
